package ribbtimq_1;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

//生产者发生消息
public class Producer {
    public static void main(String[] args) throws IOException, TimeoutException {
        ConnectionFactory c = new ConnectionFactory();
        c.setHost("192.168.64.140");
        c.setPort(5672);
        c.setUsername("admin");
        c.setPassword("admin");

        Connection ch = c.newConnection();
        Channel cha = ch.createChannel();

        cha.queueDeclare("helloWord", false, false, false, null);

        cha.basicPublish("", "helloWord",null, "helloWord".getBytes());
        System.out.println("发生成功");
        cha.close();
        ch.close();
    }
}
